package document;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import user.User;


/**
 * collection of reviews for a manuscript.
 * @author Daniel Bryant    (author for all)
 * @author Tony Butterfield (Co-Author for javadoc, add, and get methods)
 * @version 12/1/2011
 */

public class ReviewCollection 
{

  /** backing store for collection using <User, Review> as the Key/Value pair. */
  
  private Map<User, Review> my_reviews;

  /** 
   * a constructor.
   */
  public ReviewCollection()
  {
    
    my_reviews = new HashMap<User, Review>();
  }

  /**
   * adds a review to the collection.
   * @param the_user User author of the review
   * @param the_review the Review we want to add
   ********************************************************
   * @requires 
   *            the_Review != null &&
   *            the_user != null && the_user = User &&
   *            
   * @ensures   the addition of a new review object into the collection 
   */  // <<NEEDS TO FAIL IF NO FILE FOUND>>>
  public void addReview(final User the_user,  final Review the_review) 
  {
    if (the_review != null && the_user != null)
    {
      my_reviews.put(the_user, the_review);
    }
    else
    {
      throw new  IllegalArgumentException();
    }
  }
  
  /**
   * get list of Reviews.
   * @return List<Review> containing all reviews in collection
   */
  public Collection<Review> getAllReviews()
  {
    final Collection<Review> result = my_reviews.values();
    return result;
  }
   
  /**
   * gets the review that the_author submitted.
   * @param the_author User who submitted the review
   * @return the review that User the_author has submitted
   ********************************************************
   * @requires 
   * @ensures 
   */
  public Review getReviewsByAuthor(final User the_author) 
  {
    return my_reviews.get(the_author); 
  }
 

/**
 * returns size of my_manuscripts.
 * @return int size
 */
  public int size() 
  {
    return my_reviews.size();
  }



}




